﻿using GgcmsCSharp.Models;
using GgcmsCSharp.Utils;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;

namespace GgcmsCSharp.Controllers
{
    public class AdminHomeController : Controller
    {
        // GET: AdminHome
        public ActionResult Index()
        {
            var js = new JavaScriptSerializer();
            var session = System.Web.HttpContext.Current.Session;
            GgcmsMember m = (GgcmsMember)session["ggcms_loginUser"];
            if (m == null)
            {
                Response.Redirect("./AdminLogin");
            }
            else {
                ViewBag.Title = "admin";
                ViewBag.LoginUser = js.Serialize(new
                {
                    Id = m.Id,
                    UserName = m.UserName,
                    Sex = m.Sex,
                    Avatar = m.Avatar,
                    Email = m.Email,
                    Level = m.Level,
                    Phone = m.Phone,
                    Scores = m.Scores,
                });
                ViewBag.sdir = ConfigurationManager.AppSettings["StaticDir"].ToString();
            }

            return View();
        }
    }
}